Support Python 3.14 and upgrade NumPy to 2.x#519
Conversation
The test in test_scan_map.py, `test_scan_map_no_interpolation`, was simplified a lot: the first part re-implemented the code of the binner but was no longer working because of updates in AstroPy pointing precision.
For some weird reason, it fails to run with Python 3.14.3 and NumPy 2.2.6
|
I forgot to say that, unlike NumPy and AstroPy, we are not dropping support for Python 3.10, which is the reason why I did not upgrade NumPy and AstroPy to the latest version. The End of Life for Python 3.10 is scheduled for October 2026, so we have still some time before dropping support for it. |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
Every new release of ty introduces new features and checks. This makes hard to create new PR.
|
Hi @ziotom78! I have tested this PR with Python v3.14.4 and NumPy v2.2.6. All tests are passing. I also run the notebook examples, it worked without issues, except when plotting the healpix maps with In the current master branch, it works as expected. |
Hi @anand-avinash, I tried to replicate your problems, but on my case (Endeavour OS Linux, Python 3.14.5, NumPy 2.2.6, Healpy 1.19.0) everything works as expected:
@ggalloni , @paganol , can you open |
|
@anand-avinash were your tests done on a windows machine? There were some default integer dtype changes in windows in numpy 2 that could eventually point us to the reason behind this (see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#windows-default-integer) |
|
Seems very strange! I tested it again in a new environment and it produced the same error. I am running the code on my laptop with Almalinux 10.1 with the following steps for setup. git clone https://github.com/litebird/litebird_sim.git lbsim_healpy
cd lbsim_healpy
git checkout numpy2_py314
conda create -n lbsim_healpy python=3.14.4
conda activate lbsim_healpy
pip install numpy==2.2.6
pip install -e .
pip install ipykernelWith these, I get healpy v1.19.0. |
|
I see that you are using Python 3.14.4, while I am using 3.14.5. Might be that the new bugfix release fixed that very issue? According to the release notes, they reverted the garbage collector back to what Python 3.13 used (plus “154 bugfixes”). |




With the release of PySM3 3.4.4, we can finally add support for Python 3.14 and update a few dependencies; most notably, we can now drop support for NumPy 1.x and move to NumPy 2.x.
The transition was not seamless, though. It seems that
np.testing.assert_allclose()causes weird memory corruption errors when used with Py 3.14 + NumPy 2.2, so I had to change it toassert np.allclose()(which does not seem to suffer from the same problem).Because of an updated dependency on AstroPy, a few tests that relied on HealPy to convert Equatorial coordinates into Galactic coordinates started failing, probably because of an update in the transformation matrices used by AstroPy. In a few cases I modified tests to stop using HealPy to do the conversion, but for
test_scan_map.pyI realized that the very long test on the binner could be significantly simplified, as in the first part it just re-implemented the map-making equation to compare it with the result of the binner. As a consequence, this test now runs in ~50% of the time.